﻿/* $RCSFile: PortalModuleControlSI.cs $
 * Apache license v2 2011 by Christian Surieux
 * $Source: ?/ADNCRM.Core/Configuration/Settings/PortalModuleControlSI.cs $
 * $log$
 * Revision 6 2010/08/06 19:56:27  christian.surieux
 *   Added Log to All cs files
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Globalization;
using System.Web;

using AddonNice.UI.DataTypes;
using AddonNice.Diagnostics;
using AddonNice.Design;
using AddonNice.UI.WebControls;
using AddonNice.Helpers;

using AddonNice.CRMWrapper;

using Trace2    =   System.Diagnostics.Trace;

namespace AddonNice.Configuration.Settings
{
    
    /// <summary>
    /// Purpose of this claas is to separate the settings initialization process from the ASP.NET user control interface
    /// Settings for a specific ModuleID could then be initialized also from object not inside an IIS process, like some WCF or RIA services
    /// No need to load the module to read its settings.
    /// This is the base initializer for module settings, it is attached to PortalModuleControl
    /// All Modules inherit from PortalModuleControl and they should define their own initializer class which inherits from PortalModuleControlSI
    /// By convention these Initializer classes are nammed with 'ModuleName'+SI
    /// They have to override the InitSettings Interface method and to define 2 Ctors: one parameterless and another with 2 parameters
    /// The Ctors must all call the base class parameterless Ctor
    /// The Ctor with parameters must call the InitSettings method passing its parameters
    /// The first statement in the InitSettings method must be base.InitSettings
    /// The corresponding module must override the InitPortalModuleControl(ModuleSettingsDictionary bSettings) method, and instanciate its own initializer class
    /// WARNING: this method is called from the base PortalModuleControl Ctor to respect the order creation for settings (base->child->etc.)
    /// </summary>
    public class PortalModuleControlSI : ISettingsInitializer
    {

        #region local properties TBD replace with code independant from HttpContext

        public PortalSettings portalSettings
		{
			get
			{
                if ( HttpContext.Current != null )
				    return (PortalSettings) HttpContext.Current.Items[StStr.strPortalSettings];
                // in designMode try loading portal '0'
                if ( ModuleTraceSwitch.Sw.TraceVerbose )
                    Trace2.WriteLine( "[V]PortalModuleControlSI portalSettings in DESIGN MODE LOADING Portal '0'",ModuleTraceSwitch.Sw.Info);
				return new PortalSettings(0);
			}
		}

        /// <summary>
        /// Return the static Wrapper stored in PortalSecurity
        /// </summary>
        protected CRMWrapperBase Wrapper
        {
            get
            {
                return AddonNice.Security.PortalSecurity.Wrapper;
            }
        }

        /// <summary>
        /// Used to ensure that the wrapper in any DynEntity object is the current one, as they go in cache they need to refresh their wrapper 
        /// </summary>
        protected virtual void ResetWrapper(DynEntity dynEnt)
        {
            CRMWrapperBase  w   =   Wrapper;
            if ( !dynEnt.HasWrapper(w) )
                dynEnt.SetWrapper(w);
        }

        #endregion local properties TBD replace with code independant from HttpContext

        
        protected ISettingsOwner _Owner =   null;
        public virtual ISettingsOwner Owner
        {
            get
            {
                return _Owner;
            }
            set
            {
                _Owner = value;
            }
        }

        
        /// <summary>
        /// Ctor used by derived classes
        /// </summary>
        public PortalModuleControlSI()
        {
            if ( ModuleTraceSwitch.Sw.TraceVerbose )
                Trace2.WriteLine( "[V]PortalModuleControlSI Empty Ctor Called.",ModuleTraceSwitch.Sw.Info);
        }

        /// <summary>
        /// Ctor when using a simple portalModule...
        /// </summary>
        public PortalModuleControlSI(ModuleSettingsDictionary bSettings,ISettingsOwner pm)
        {
            if ( ModuleTraceSwitch.Sw.TraceVerbose )
                Trace2.WriteLine( "[V]PortalModuleControlSI Ctor BEG.",ModuleTraceSwitch.Sw.Info);
            InitSettings(bSettings,pm);
            if ( ModuleTraceSwitch.Sw.TraceVerbose )
                Trace2.WriteLine( "[V]PortalModuleControlSI Ctor BEG.",ModuleTraceSwitch.Sw.Info);
        }
        
        /// <summary>
        /// Interface Method to init settings
        /// </summary>
        public virtual void InitSettings(ModuleSettingsDictionary bSettings)
        {             
            if ( ModuleTraceSwitch.Sw.TraceVerbose )
                Trace2.WriteLine( "[V]PortalModuleControlSI InitSettings BEG.",ModuleTraceSwitch.Sw.Info);
            InitSettings(bSettings,null);
        }

        /// <summary>
        /// Interface Method to init settings, pm could be null
        /// </summary>
        public virtual void InitSettings(ModuleSettingsDictionary bSettings,ISettingsOwner pm)
        {             
            if ( ModuleTraceSwitch.Sw.TraceVerbose )
                Trace2.WriteLine( "[V]PortalModuleControlSI InitSettings BEG.",ModuleTraceSwitch.Sw.Info);
			
            Owner   =   pm; // save the owner

            #region Layout Management
			
            SettingItemGroup _Group			                =   SettingItemGroup.LAYOUT_SETTINGS;
			int _groupOrderBase				                =   (int)SettingItemGroup.LAYOUT_SETTINGS;

			SettingItem ApplyLayout		                    =   new SettingItem(StStr.ModuleSettingsApplyModuleLayout,new BooleanDataType());
			ApplyLayout.Order			                    =   _groupOrderBase + 10;
			ApplyLayout.Group			                    =   _Group;
			ApplyLayout.Value			                    =   StStr.strTrue;
			ApplyLayout.EnglishName		                    =   "Apply Module Layout";
			ApplyLayout.Description		                    =   "Check this box to apply selected layout to this module";
            ApplyLayout.Type                                =    SettingsType.Module;
			bSettings.AddSetting(ApplyLayout);

			ArrayList ModuleLayoutOptions		            =   new ArrayList();
            ModuleLayoutOptions.Add(new SettingOption((int)ModuleLayoutOption.Default, LocalizeHelper.Localize(StStr.ModuleSettingsModuleLayoutDefault, StStr.DefaultModulesLayout)));
            ModuleLayoutOptions.Add(new SettingOption((int)ModuleLayoutOption.Alt, LocalizeHelper.Localize(StStr.ModuleSettingsModuleLayoutAlt, StStr.AltModulesLayout)));
			
            SettingItem ModuleLayout			            =   new SettingItem(StStr.ModuleSettingsModuleLayout,new CustomListDataType(ModuleLayoutOptions,StStr.Name,StStr.Val));
			ModuleLayout.Order					            =   _groupOrderBase + 20;
			ModuleLayout.Group					            =   _Group;
			ModuleLayout.Value					            =   ((int)ModuleLayoutOption.Default).ToString();
			ModuleLayout.EnglishName			            =   "Module Layout";
			ModuleLayout.Description			            =   "Choose a layout for this module";
            ModuleLayout.Type                               =   SettingsType.Module;
			bSettings.AddSetting(ModuleLayout);

			SettingItem ApplyLayoutNoSkin                   =   new SettingItem(StStr.ModuleSettingsApplyLayoutNoSkin,new BooleanDataType());
			ApplyLayoutNoSkin.Order			                =   _groupOrderBase + 22;
			ApplyLayoutNoSkin.Group			                =   _Group;
			ApplyLayoutNoSkin.Value			                =   StStr.strFalse;
			ApplyLayoutNoSkin.EnglishName		            =   "No layout skin when no header";
			ApplyLayoutNoSkin.Description		            =   "Don't apply layout skin when no header";
            ApplyLayoutNoSkin.Type                          =    SettingsType.Module;
			bSettings.AddSetting(ApplyLayoutNoSkin);

            // if site allows custom Layout for modules, try to find one
            if ( portalSettings.AllowCustomModulesLayout )
			{
                // Historical layouts necessary for xml web parts
				ArrayList ModulesLayoutList			        =	new ModulesLayoutManager(portalSettings.PortalPath).GetModulesLayouts();
				ModulesLayoutItem _noCustomLayout	        =	new ModulesLayoutItem(string.Empty,ItemOrigin.None);
				ModulesLayoutList.Insert(0,_noCustomLayout);
				SettingItem ModuleCustomLayout	            =	new SettingItem(StStr.ModuleSettingsModuleModuleLayout,
                                                            new CustomListDataType(ModulesLayoutList,StStr.Name,StStr.Name));
				ModuleCustomLayout.Order			        =	_groupOrderBase + 25;
				ModuleCustomLayout.Group			        =	_Group;
				ModuleCustomLayout.EnglishName		        =	"Custom Module Layout";
				ModuleCustomLayout.Description		        =	"Set a custom layout for this module only";
                ModuleCustomLayout.Type                     =   SettingsType.Module;
				bSettings.AddSetting(ModuleCustomLayout);
            }
            
            // switches title display on/off
			SettingItem ShowTitle			            =	new SettingItem(StStr.ModuleSettingsShowTitle,new BooleanDataType());
			ShowTitle.Order					            =	_groupOrderBase + 30;
			ShowTitle.Group					            =	_Group;
			ShowTitle.Value					            =	StStr.strTrue;
			ShowTitle.EnglishName			            =	"Show Title";
			ShowTitle.Description			            =	"Switches title display on/off";
            ShowTitle.Type                              =   SettingsType.Module;
			bSettings.AddSetting(ShowTitle);

			
			//  - implement width, height, and content scrolling options for all modules 
			//  - implement auto-stretch option
			//Windows height
			SettingItem ControlHeight		            =	new SettingItem(StStr.ModuleSettingsContentHeight,new UnitDataType());
			ControlHeight.Value				            =	"0";
			//ControlHeight.MinValue			        =	0;
			//ControlHeight.MaxValue			        =	3000;
			ControlHeight.Required			            =	true;
			ControlHeight.Order				            =	_groupOrderBase + 50;
			ControlHeight.Group				            =	_Group;
			ControlHeight.EnglishName		            =	"Content Height";
			ControlHeight.Description		            =	"Minimum height(in pixels) of the content area of this module. (0 for none)";
            ControlHeight.Type                          =   SettingsType.Module;
            bSettings.AddSetting(ControlHeight);

			//Windows width
			SettingItem ControlWidth		            =	new SettingItem(StStr.ModuleSettingsContentWidth,new UnitDataType());
			ControlWidth.Value				            =	"0";
			//ControlWidth.MinValue			            =	0;
			//ControlWidth.MaxValue			            =	3000;
			ControlWidth.Required			            =	true;
			ControlWidth.Order				            =	_groupOrderBase + 60;
			ControlWidth.Group				            =	_Group;
			ControlWidth.EnglishName		            =	"Content Width";
			ControlWidth.Description		            =	"Width of the content area of this module. (0 for none)";
            ControlWidth.Type                           =   SettingsType.Module;
            bSettings.AddSetting(ControlWidth);
			
			//Content scrolling option
			SettingItem ScrollingSetting	            =	new SettingItem(StStr.ModuleSettingsContentScrolling,new BooleanDataType());
			ScrollingSetting.Value			            =	StStr.strFalse;
			ScrollingSetting.Order			            =	_groupOrderBase + 70;
			ScrollingSetting.Group			            =	_Group;
			ScrollingSetting.EnglishName	            =	"Content Scrolling";
			ScrollingSetting.Description	            =	"Set to enable/disable scrolling of Content based on height and width settings.";
            ScrollingSetting.Type                       =   SettingsType.Module;
            bSettings.AddSetting(ScrollingSetting);
			
			//Module Stretching option
			SettingItem StretchSetting		            =	new SettingItem(StStr.ModuleSettingsWidthStretching,new BooleanDataType());
			StretchSetting.Value			            =	StStr.strTrue;
			StretchSetting.Order			            =	_groupOrderBase + 80;
			StretchSetting.Group			            =	_Group;
			StretchSetting.EnglishName		            =	"Module Auto Stretch";
			StretchSetting.Description		            =	"Set to enable/disable automatic stretching of the module's width to fill the empty area to the right of the module.";
            StretchSetting.Type                         =   SettingsType.Module;
			bSettings.AddSetting(StretchSetting);
			
            #endregion

            #region advanced layout

            _Group			                            =   SettingItemGroup.ADVANCED_LAYOUT_SETTINGS;
			_groupOrderBase				                =   (int)_Group;

			SettingItem UseInnerDiv		                =	new SettingItem(StStr.ModuleSettingsUseInnerDiv,new BooleanDataType());
			UseInnerDiv.Value			                =	StStr.strTrue;
			UseInnerDiv.Order			                =	_groupOrderBase + 10;
			UseInnerDiv.Group			                =	_Group;
			UseInnerDiv.EnglishName		                =	"Use external Div";
			UseInnerDiv.Description		                =	"Use an external div element around the module div itself.";
            UseInnerDiv.Type                            =   SettingsType.Module;
			bSettings.AddSetting(UseInnerDiv);

            SettingItem ExtCssClassSetting		        =	new SettingItem(StStr.ModuleSettingsExtCssClass,new StringDataType());
			ExtCssClassSetting.Order			        =	_groupOrderBase + 20;
			ExtCssClassSetting.Group			        =	_Group;
			ExtCssClassSetting.EnglishName		        =	"External Div Css class";
			ExtCssClassSetting.Description		        =	"This Css class will be applied to the external div element of module.";
            ExtCssClassSetting.Type                     =   SettingsType.Module;
			bSettings.AddSetting(ExtCssClassSetting);

			SettingItem ExtStyleSetting		            =	new SettingItem(StStr.ModuleSettingsExtStyle,new StringDataType());
			ExtStyleSetting.Order			            =	_groupOrderBase + 30;
			ExtStyleSetting.Group			            =	_Group;
			ExtStyleSetting.EnglishName		            =	"External Div Style";
			ExtStyleSetting.Description		            =	"This Css style will be applied to the external div element of module.";
            ExtStyleSetting.Type                        =   SettingsType.Module;
			bSettings.AddSetting(ExtStyleSetting);

            SettingItem CssClassSetting		            =	new SettingItem(StStr.ModuleSettingsCssClass,new StringDataType());
			CssClassSetting.Order			            =	_groupOrderBase + 40;
			CssClassSetting.Group			            =	_Group;
			CssClassSetting.EnglishName		            =	"Module Css class";
			CssClassSetting.Description		            =	"This Css class will be applied to the div element of module.";
            CssClassSetting.Type                        =   SettingsType.Module;
			bSettings.AddSetting(CssClassSetting);

			SettingItem StyleSetting		            =	new SettingItem(StStr.ModuleSettingsStyle,new StringDataType());
			StyleSetting.Order			                =	_groupOrderBase + 50;
			StyleSetting.Group			                =	_Group;
			StyleSetting.EnglishName		            =	"Module Style";
			StyleSetting.Description		            =	"This Css style will be applied to the div element of module.";
            StyleSetting.Type                           =   SettingsType.Module;
			bSettings.AddSetting(StyleSetting);

			ArrayList ModulePos	                        =	new ArrayList();
			ModulePos.Add(new NameListItem("absolute"));
			ModulePos.Add(new NameListItem("fixed"));
			ModulePos.Add(new NameListItem("relative"));
			ModulePos.Add(new NameListItem("static"));

			SettingItem CssPosition		                =	new SettingItem(StStr.ModuleSettingsDefaultCssPosition,new CustomListDataType(ModulePos,StStr.Name,StStr.Name));
			CssPosition.Order			                =	_groupOrderBase + 60;
			CssPosition.Value                           =	"relative"; // to be able to position block elements in modules in absolute position
			CssPosition.Group			                =	_Group;
			CssPosition.EnglishName		                =	"Module Default position";
			CssPosition.Description		                =	"If no css style is defined for module, this position will be used in style for its div.";
            CssPosition.Type                            =   SettingsType.Module;
			bSettings.AddSetting(CssPosition);
            
			SettingItem UseOverflow		                =	new SettingItem(StStr.ModuleSettingsUseOverflow,new BooleanDataType());
			UseOverflow.Order			                =	_groupOrderBase + 70;
			UseOverflow.Value                           =	StStr.strFalse;
			UseOverflow.Group			                =	_Group;
			UseOverflow.EnglishName		                =	"Module use overflow";
			UseOverflow.Description		                =	"When the module is not a scrolling one, should we use a css overflow style.";
            UseOverflow.Type                            =   SettingsType.Module;
			bSettings.AddSetting(UseOverflow);

            SettingItem DefaultCssOverflow		        =	new SettingItem(StStr.ModuleSettingsDefaultCssOverflow,new StringDataType());
			DefaultCssOverflow.Order			        =	_groupOrderBase + 80;
			DefaultCssOverflow.Value                    =	"auto";
			DefaultCssOverflow.Group			        =	_Group;
			DefaultCssOverflow.EnglishName		        =	"Module default overflow";
			DefaultCssOverflow.Description		        =	"If no css style is defined for module, this overflow parameter will be used in style for its div.";
            DefaultCssOverflow.Type                     =   SettingsType.Module;
			bSettings.AddSetting(DefaultCssOverflow);
            
            #endregion


            #region Buttons
            _Group							            =	SettingItemGroup.BUTTON_DISPLAY_SETTINGS;
			_groupOrderBase					            =	(int)SettingItemGroup.BUTTON_DISPLAY_SETTINGS;

			// choices for Button display on module
			ArrayList buttonDisplayOptions	            =	new ArrayList();
			buttonDisplayOptions.Add(new SettingOption((int)ModuleButton.RenderOptions.ImageOnly , LocalizeHelper.Localize("MODULESETTINGS_BUTTON_DISPLAY_IMAGE", "Image only")));
			buttonDisplayOptions.Add(new SettingOption((int)ModuleButton.RenderOptions.TextOnly , LocalizeHelper.Localize("MODULESETTINGS_BUTTON_DISPLAY_TEXT", "Text only")));
			buttonDisplayOptions.Add(new SettingOption((int)ModuleButton.RenderOptions.ImageAndTextCSS , LocalizeHelper.Localize("MODULESETTINGS_BUTTON_DISPLAY_BOTH", "Image and Text (CSS)")));
			buttonDisplayOptions.Add(new SettingOption((int)ModuleButton.RenderOptions.ImageOnlyCSS , LocalizeHelper.Localize("MODULESETTINGS_BUTTON_DISPLAY_IMAGECSS", "Image only (CSS)")));
			
            SettingItem ButtonDisplay		            =	new SettingItem(StStr.ModuleSettingsButtonDisplay,new CustomListDataType(buttonDisplayOptions,StStr.Name,StStr.Val));
			ButtonDisplay.Order				            =	_groupOrderBase + 30;
			ButtonDisplay.Group				            =	_Group;
			ButtonDisplay.Value				            =	((int)ModuleButton.RenderOptions.ImageOnly).ToString();
			ButtonDisplay.EnglishName		            =	"Display Buttons as:";
			ButtonDisplay.Description		            =	"Choose how you want module buttons to be displayed. Note that settings other than 'Image only' may require Zen or special treatment in the ModulesLayout.";
            ButtonDisplay.Type                          =   SettingsType.Module;
			bSettings.AddSetting(ButtonDisplay);

			// Show arrows buttons to move modules (admin only, property authorise)
			SettingItem ArrowButtons		            =	new SettingItem(StStr.ModuleSettingsShowArrowButtons,new BooleanDataType());
			ArrowButtons.Value				            =	StStr.strTrue;
			ArrowButtons.Order				            =	_groupOrderBase + 40;
			ArrowButtons.Group				            =	_Group;
			ArrowButtons.EnglishName		            =	"Show Arrow Admin Buttons";
			ArrowButtons.Description		            =	"Show Arrow Admin buttons?";
            ArrowButtons.Type                           =   SettingsType.Module;
			bSettings.AddSetting(ArrowButtons);

			SettingItem ButtonsAsPopup                  =	new SettingItem(StStr.ModuleSettingsModuleButtonsAsPopup,new BooleanDataType());
			ButtonsAsPopup.Value				        =	StStr.strFalse;
			ButtonsAsPopup.Order				        =	_groupOrderBase + 45;
			ButtonsAsPopup.Group				        =	_Group;
			ButtonsAsPopup.EnglishName		            =	"Buttons as popup";
			ButtonsAsPopup.Description		            =	"Buttons will be popup ?";
            ButtonsAsPopup.Type                         =   SettingsType.Module;
			bSettings.AddSetting(ButtonsAsPopup);

            // Show help button if exists
			SettingItem HelpButton			            =	new SettingItem(StStr.ModuleSettingsShowHelpButton,new BooleanDataType());
			HelpButton.Value				            =   StStr.strFalse;
			HelpButton.Order				            =	_groupOrderBase + 50;
			HelpButton.Group				            =	_Group;
			HelpButton.EnglishName			            =	"Show Help Button";
			HelpButton.Description			            =	"Show help button in title if exists documentation for this module";
            HelpButton.Type                             =   SettingsType.Module;
			bSettings.AddSetting(HelpButton);

			#endregion

			#region Language/Culture Management
			_groupOrderBase					            =	(int)SettingItemGroup.CULTURE_SETTINGS;
			_Group							            =	SettingItemGroup.CULTURE_SETTINGS;

            CultureInfo[] cultureList                   =   PortalModuleControl.GetLanguageList(true);
			
			SettingItem Culture				            =	new SettingItem(StStr.ModuleSettingsCulture,new MultiSelectListDataType(cultureList,  "DisplayName", StStr.Name));
			Culture.Value					            =	string.Empty;
			Culture.Order					            =	_groupOrderBase + 10;
			Culture.Group					            =	_Group;
			Culture.EnglishName				            =	"Culture";
			Culture.Description				            =	"Choose culture. Invariant cultures shows the module always.";
            Culture.Type                                =   SettingsType.Module;
			bSettings.AddSetting(Culture);

			//Localized module title
			int counter						            =	_groupOrderBase + 11;
			foreach(System.Globalization.CultureInfo c in cultureList)
			{
                // '-' are not supported for resources
                string strlang = c.Name.ToUpper().Replace('-', '_');
                //Ignore invariant
                if (c != System.Globalization.CultureInfo.InvariantCulture && !bSettings.ContainsUpperKey(strlang))
				{
                    SettingItem LocalizedTitle      =   new SettingItem("MODULESETTINGS_TITLE_"+strlang,new StringDataType());
					LocalizedTitle.Order		    =	counter;
					LocalizedTitle.Group		    =	_Group;
					LocalizedTitle.EnglishName	    =	"Title (" + c.Name + ")";
					LocalizedTitle.Description	    =	"Set title for " + c.EnglishName + " culture.";
                    LocalizedTitle.Type             =   SettingsType.Module;
					bSettings.AddSetting(LocalizedTitle);
					counter++;
				}
			}
			#endregion

			// CS 7/12/04 this is Added to manage Portal Settings extensions which could be necessary to some Package like E-Commerce
            ModuleSettingsCreatedEventArgs e	    =	new ModuleSettingsCreatedEventArgs(bSettings,pm);
			bSettings.OnModuleSettingsCreated(e);
            
            if ( ModuleTraceSwitch.Sw.TraceVerbose )
                Trace2.WriteLine( "[V]PortalModuleControlSI InitSettings END.",ModuleTraceSwitch.Sw.Info);
        }
    }

    /// <summary>
    /// Initializer for PortalCRMModuleControl
    /// </summary>
    public class PortalCRMModuleControlSI : PortalModuleControlSI
    {
        public PortalCRMModuleControlSI()
        {
            if ( ModuleTraceSwitch.Sw.TraceVerbose )
                Trace2.WriteLine( "[V]PortalCRMModuleControlSI Empty Ctor Called.",ModuleTraceSwitch.Sw.Info);
        }

        public PortalCRMModuleControlSI(ModuleSettingsDictionary _baseSettings,ISettingsOwner pm) : base()
        {
            if ( ModuleTraceSwitch.Sw.TraceVerbose )
                Trace2.WriteLine( "[V]PortalCRMModuleControlSI Ctor BEG.",ModuleTraceSwitch.Sw.Info);
            InitSettings(_baseSettings,pm);
            if ( ModuleTraceSwitch.Sw.TraceVerbose )
                Trace2.WriteLine( "[V]PortalCRMModuleControlSI Ctor END.",ModuleTraceSwitch.Sw.Info);
        }
 
        public override void InitSettings(ModuleSettingsDictionary bSettings,ISettingsOwner pm)
        {             
            if ( ModuleTraceSwitch.Sw.TraceVerbose )
                Trace2.WriteLine( "[V]PortalModuleControlSI InitSettings BEG.",ModuleTraceSwitch.Sw.Info);
            
            base.InitSettings(bSettings,pm);
            
            #region CRM settings
            SettingItemGroup _Group                 =   SettingItemGroup.CRM_SETTINGS;

            SettingItem EntityNameSetting           =   new SettingItem(StStr.ModuleSettingsCRMEntityNameSettings,new StringDataType());
            EntityNameSetting.Order                 =   1;
            EntityNameSetting.Group                 =   _Group;
            EntityNameSetting.Value                 =   string.Empty;
            EntityNameSetting.EnglishName           =   "EntityName";
            EntityNameSetting.Description           =   "Name of CRM entity associated to this module (leave blank if no entity associated).";
            bSettings.AddSetting(EntityNameSetting);

            SettingItem Default2PageEntityName		=   new SettingItem(StStr.ModuleSettingsCRMDefault2PageEntityName,new BooleanDataType());
            Default2PageEntityName.Order		    =   3;
            Default2PageEntityName.Group		    =   _Group;
            Default2PageEntityName.Value			=   StStr.strTrue;
            Default2PageEntityName.EnglishName		=   "Default EntityName to Page";
            Default2PageEntityName.Description		=   "Default the module entity name to page entity Name";
            bSettings.AddSetting(Default2PageEntityName);

            SettingItem DisplayProperty				=   new SettingItem(StStr.ModuleSettingsCRMEntityDisplayProperty,new StringDataType());
            DisplayProperty.Order					=   5;
            DisplayProperty.Group					=   _Group;
            DisplayProperty.Value					=   string.Empty;
            DisplayProperty.EnglishName				=   "CRM Display property name";
            DisplayProperty.Description				=   "Nom schéma de la propriété CRM affichée";
            bSettings.AddSetting(DisplayProperty);

            #endregion
		}
    }
}
